import time


def inti_file(filen):
    for i in range(len(filen)):
        filen[i] = int(filen[i])
    return filen


def read_file(filename):
    file = open(filename, 'r')
    s = file.readlines()
    return s


def sort_file(filename2):
    sw = True
    while sw:
        sw = False
        for j in range(len(filename2) - 1):
            if int(filename2[j]) > int(filename2[j + 1]):
                filename2[j], filename2[j + 1] = filename2[j + 1], filename2[j]
                sw = True
    return filename2


m1 = read_file('m1_sorted.txt')
m1 = inti_file(m1)
start = time.time()
sort_file(m1)
finish = time.time()
print('m1_sorted.txt', round((finish - start) * 1000), 'milliseconds')

m2 = read_file('m2_reverse.txt')
m2 = inti_file(m2)
start = time.time()
sort_file(m2)
finish = time.time()
print('m2_reverse.txt', round((finish - start) * 1000), 'milliseconds')

m3 = read_file('m3_shuffle.txt')
m3 = inti_file(m3)
start = time.time()
sort_file(m3)
finish = time.time()
print('m3_shuffle.txt', round((finish - start) * 1000), 'milliseconds')